<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Strict//EN">
<html>

<head>
<meta http-equiv="Content-Language" content="en-us">
<title>simSendData</title>
<link rel="stylesheet" type="text/css" href="../../style.css">
</head>

<body>

<div align="center">
<table class=allEncompassingTable >
 <tr>
  <td >
<p><a href="../../index.html" TARGET="_top"><img src="../images/homeImg.png"></a></p>

<h1><a href="../apiOverview.htm">Regular API</a> function</h1>
<h3 class=subsectionBar><a name="simSendData" id="simSendData"></a>simSendData / sim.sendData </h3>
<table class=apiTable>
<tr class=apiTableTr> 
<td class=apiTableLeftDescr>
Description 
</td> 
<td class=apiTableRightDescr>Sends (or broadcasts) wireless data (in a simulation). See also <a href="simReceiveData.htm">sim.receiveData</a> and <a href="simTubeOpen.htm">sim.tubeOpen</a>. Cannot be called from <a href="../addOns.htm">add-ons</a>. <br>
<br>
Wireless emissions can be visualized globally via the <a href="../environmentPropertiesDialog.htm">environment dialog</a>, or individually as in following example:
<pre class=lightRedBoxNoMarginAndSmall>
sim.setBoolParameter(sim.boolparam_force_show_wireless_emission,true)
sim.sendData(...)
sim.setBoolParameter(sim.boolparam_force_show_wireless_emission,false)</pre>

</td>
</tr> 
<tr class=apiTableTr> 
<td class=apiTableLeftCSyn>
C synopsis
</td> 
<td class=apiTableRightCSyn>simInt simSendData(simInt targetID,simInt dataHeader,const simChar* dataName,const simChar* data,simInt dataLength,simInt antennaHandle,simFloat actionRadius,simFloat emissionAngle1,simFloat emissionAngle2,simFloat persistence)<br></td> 
</tr> 
<tr class=apiTableTr> 
<td class=apiTableLeftCParam>C parameters</td> 
<td class=apiTableRightCParam>
<div><strong>targetID</strong>: indicates what receivers will receive the message. Can be sim_handle_all, or the handle of a script<br>
</div>
<div><strong>dataHeader</strong>: number indicating who &quot;designed&quot; the communication message. Always use the same header (because only you will know the meaning of the message) and stick to it. The best is to use the serial number of your CoppeliaSim copy (check the &quot;Help&quot; menu, in the &quot;About&quot; item for the serial number). Otherwise, you risk collision with other developer's messages which might use the same header as yours.<br>
</div>
<div><strong>dataName</strong>: name indicating the type of message. dataHeader and dataName will be used to filter out all unwanted messages when trying to receive a specific message (see <a href="simReceiveData.htm">simReceiveData</a>)<br>
</div>
<div><strong>data</strong>: data to transmit</div>
<div><strong>dataLength</strong>: length of the data to transmit</div>
<div><strong>antennaHandle</strong>: handle of the scene object that should operate as the antenna for this transmission. Use sim_handle_default to simulate an antenna coinciding with the world reference frame<br>
</div>
<div><strong>actionRadius</strong>: radius of the transmission area. If the sender's antenna and receiver's antenna are farther apart than the actionRadius, the receiver can't receive the data<br>
</div>
<div><strong>emissionAngle1</strong>: opening angle of the transmission area, vertically (along the antenna's z-axis). Value can vary between 0 and pi. If pi, and emissionAngle2 is 2pi, then the transmission area is spherical.<br>
</div>
<div><strong>emissionAngle2</strong>: opening angle of the transmission area, horizontally (along the antenna's x/y-axis). Value can vary between 0 and 2pi. If 2pi, and emissionAngle1 is pi, then the transmission area is spherical.<br>
</div>
<div><strong>persistence</strong>: the simulation time duration after which the data is not available to receivers anymore, or 0.0 for a persistence of 1.5*simulationTimeStep (default)<br>
</div>
<div></div></td> 
</tr> 
<tr class=apiTableTr> 
<td class=apiTableLeftCRet>
C return value
</td> 
<td class=apiTableRightCRet>
<div>-1 if operation was not successful<br>
</div>
</td> 
</tr> 
<tr class=apiTableTr> 
<td class=apiTableLeftLSyn>
Lua synopsis
</td> 
<td class=apiTableRightLSyn>sim.sendData(number targetID,number dataHeader,string dataName,string data,number antennaHandle=sim.handle_self,number actionRadius=100,number emissionAngle1=3.1415,number emissionAngle2=6.283,number persistence=0)<br></td> 
</tr> 
<tr class=apiTableTr> 
<td class=apiTableLeftLParam>Lua parameters</td> 
<td class=apiTableRightLParam>
<div><strong>targetID</strong>: indicates what receivers will receive the message. Can be sim.handle_all, sim.handle_tree, sim.handle_chain, or the handle of a script. If sim.handle_tree is specified, then only child scripts built on top of current script's hierarchy will be able to receive the message. If sim.handle_chain is specified, then only child scripts parented with current script (or the main script) will be able to receive the message<br>
</div>
<div><strong>dataHeader</strong>: number indicating who &quot;designed&quot; the communication message. Always use the same header (because only you will know the meaning of the message) and stick to it. The best is to use the serial number of your CoppeliaSim copy (check the &quot;Help&quot; menu, in the &quot;About&quot; item for the serial number). Otherwise, you risk collision with other developer's messages which might use the same header as yours.<br>
</div>
<div><strong>dataName</strong>: name indicating the type of message. dataHeader and dataName will be used to filter out all unwanted messages when trying to receive a specific message (see <a href="simReceiveData.htm">sim.receiveData</a>)<br>
</div>
<div><strong>data</strong>: data to transmit (each character can have values between 0 and 255). See also the <a href="../apiFunctionListCategory.htm#packing">data packing/unpacking functions</a>.</div>
<div><strong>antennaHandle</strong>: handle of the scene object that should operate as the antenna for this transmission. Use sim.handle_default to simulate an antenna coinciding with the world reference frame, or sim.handle_self to use the object associated with the child script as antenna. Can be omitted (in that case, sim.handle_self is used)<br>
</div>
<div><strong>actionRadius</strong>: Similar to the C-function counterpart. Can be omitted (in that case 100 is used)</div>
<div><strong>emissionAngle1</strong>: Similar to the C-function counterpart. Can be omitted (in that case, pi is used)</div>
<div><strong>emissionAngle2</strong>: Similar to the C-function counterpart. Can be omitted (in that case, 2pi is used)</div>
<div><strong>persistence</strong>: Similar to the C-function counterpart. Can be omitted (in that case, 0.0 is used)</div>
<div></div></td> 
</tr> 
<tr class=apiTableTr> 
<td class=apiTableLeftLRet>
Lua return values
</td> 
<td class=apiTableRightLRet>
<div>none</div></td> 
</tr> 
</table> 

<br>
<p><a href="../apiFunctions.htm">All regular API functions on one page</a></p>
<br>
<br>
</td>
</tr>
</table>
</div>
</body>
</html>
